package org.example.poiwebtest.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;


import javax.validation.constraints.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;


@Data
@AllArgsConstructor
@NoArgsConstructor
public class PhoneDTO {
    public PhoneDTO(int id, String phoneName, BigDecimal cost, LocalDateTime createTime) {
        this.id = id;
        this.phoneName = phoneName;
        this.cost = cost;
        this.createTime = createTime;
    }

    @Max(value = 15, message = "最大不能超过15")
    @Min(value = 3, message = "最小不能小于3")
    @Excel(name = "商品id", width = 15, orderNum = "10")
    @NotNull(message = "商品id不能为空哦!!!")
    private int id;

    @Length(max = 2)
    @Excel(name = "手机名", width = 15, orderNum = "20")
    @NotNull(message = "用户名不能为空哦!!")
    private String phoneName;

    @Excel(name = "价格", width = 15, orderNum = "30")
    @NotNull(message = "价格不能为空!!")
    @Digits(integer = 3, fraction = 2, message = "整数位最多3位,小数位最多2位")
    @DecimalMin(value = "0", message = "成本不能为负数")
    private BigDecimal cost;

    @Excel(name = "时间", exportFormat = "yyyy-MM-dd HH:mm:ss", importFormat = "yyyy-MM-dd HH:mm:ss", width = 25, orderNum = "40")
    private LocalDateTime createTime;

    //	String类型可以使用正则校验
    @Pattern(regexp = "^[1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*$", message = "必须为金额数值")
    private String money;

}
